home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Audio-DSP / NU / Source / Terminator.m < prev    next >
Encoding:
Text File  |  1992-04-05  |  1.6 KB  |  82 lines

  1. #import "Terminator.h"
  2. #import <appkit/Application.h>
  3. /**
  4.  ** Terminators are often called "sentinels"
  5.  ** in CS literature.  They are used stop off
  6.  ** the is, than, and ancestor pointers in
  7.  ** a glyph. They generally function a
  8.  ** the basis of recursive calls on a 
  9.  ** TTree.  There really is only one
  10.  ** Terminator, returned by the new message.
  11.  ** If we could get doesNotUnderstand: to
  12.  ** work with factory objects, 
  13.  ** then this class could be all
  14.  ** class methods.
  15.  **/ 
  16.  
  17. static Terminator * _soleInstanceOfTerminator = nil ;
  18.  
  19. @implementation Terminator: Object
  20.  
  21. + new ;
  22. { if(!_soleInstanceOfTerminator)
  23.   { _soleInstanceOfTerminator = [super new] ;
  24.     _soleInstanceOfTerminator->flags.isTerminator = 1 ;
  25.   }
  26.   return _soleInstanceOfTerminator ;
  27. }
  28.  
  29. - (BOOL) become: newClass if: oldClass ;
  30. { return NO ;
  31. }
  32.  
  33. - doesNotRecognize: (SEL)aSelector ;
  34. { // if I don't recognize something,
  35.   // I just return
  36.   return self ;
  37. }
  38.  
  39. - enlist: (Glyph *) aGlyt ;
  40. { // I will terminate this Glist
  41.   aGlyt->then = (Glyph *) self ;
  42.   return aGlyt ;
  43. }
  44.  
  45. - free ;
  46. { // I cannot be freed!
  47.   return self ;
  48. }
  49.  
  50. -hitTest: (NXPoint *) aPnt ;
  51. { return nil ;
  52. }
  53.  
  54. - (char *) iam ;
  55. // remove: debugging purposes only
  56. { return "Term" ;
  57. }
  58.  
  59. - (BOOL) isTerminator ;
  60. { return YES ;
  61. }
  62.  
  63. - (BOOL) precedes: (Glyph *) aGlyph ;
  64. { // Terminators cannot precede anything
  65.   return NO ;
  66. }
  67.  
  68.  
  69. - test: (int) anInt ;
  70. { // remove when you are satisfied...
  71. //  [NXApp printf: "T%d\n", anInt] ;
  72.   return self ;
  73. }
  74.  
  75.  
  76. - finishUnarchiving ;
  77. { // don't use the unarchived instance!
  78.   [self free] ;
  79.   return [Terminator new] ;
  80. }
  81.  
  82. @end